package com.pcbly.web.action.system;

import java.util.List;

import com.pcbly.web.action.BaseAction;
import com.pcbly.web.bean.system.GroupBean;
import com.pcbly.web.business.group.GroupService;

public class GroupAction extends BaseAction<GroupBean> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2928355743932494017L;
	private GroupService groupService;
	private GroupBean groupBean;
	private List<GroupBean> groupBeans;

	public String index() throws Exception {
		groupBeans = groupService.findGroupBeans();
		return super.index();
	}

	public String dwrSave(GroupBean bean) throws Exception {
		if (bean.getId() == null || "".equals(bean.getId())) {
			groupService.saveGroupBean(bean);
		} else {
			groupService.updateGroupBean(bean);
		}
		return "ok";
	}

	public String dwrDelete(String id) throws Exception {
		groupService.deleteGroupBeanById(id);
		return "ok";
	}

	public GroupBean dwrView(String id) throws Exception {
		groupBean = groupService.getGroupBeanById(id);
		return groupBean;
	}

	public GroupBean getGroupBean() {
		return groupBean;
	}

	public void setGroupBean(GroupBean groupBean) {
		this.groupBean = groupBean;
	}

	public List<GroupBean> getGroupBeans() {
		return groupBeans;
	}

	public void setGroupBeans(List<GroupBean> groupBeans) {
		this.groupBeans = groupBeans;
	}

	public void setGroupService(GroupService groupService) {
		this.groupService = groupService;
	}

}
